package com.asu.dltalk.main;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class TalkWindow {
	protected Shell shell;
	private String name;
	private Text tWindow;
	private Text tPanel;
	
	public TalkWindow() {}
	public TalkWindow(String name){
		try {
			this.name = name;
			TalkWindow window = new TalkWindow();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
	
	protected void createContents() {
		shell = new Shell();	
		shell.setSize(419, 390);
		shell.setText("Talking to "+ name +"...");
		
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setBounds(10, 10, 383, 332);
		
		tWindow = new Text(composite, SWT.BORDER);
		tWindow.setEditable(false);
		tWindow.setBounds(10, 10, 363, 208);
		
		tPanel = new Text(composite, SWT.BORDER);
		tPanel.setBounds(10, 224, 363, 72);
		
		Button btnClear = new Button(composite, SWT.NONE);
		btnClear.setBounds(204, 302, 75, 25);
		btnClear.setText("Clear");
		
		Button btnSend = new Button(composite, SWT.NONE);
		btnSend.setBounds(298, 302, 75, 25);
		btnSend.setText("Send");
	}
}
